<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2017/12/29
 * Time: 18:32
 */

namespace App;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Standard extends Model
{
    use SoftDeletes;
    // 表名称
    protected $table = 'standard';
    // 开启自动时间戳
    public $timestamps = true;
    // 日期都存储为时间戳
    protected $dateFormat = 'U';

    // 追加status_bool字段,status的布尔类型
    public function getStatusBoolAttribute()
    {
        return $this->attributes['status'] ? 'true' : false;
    }

    public function category()
    {
        return $this->belongsToMany('App\Category', 'category_mapping_standard', 'standard_id', 'category_id');
    }
}